export default function PalettProvider(
  palette,
  create,
  elementFactory,
  globalConnect
) {
  this.create = create;
  this.elementFactory = elementFactory;
  this.globalConnect = globalConnect;

  palette.registerProvider(this);
}

PalettProvider.$inject = [
  "palette",
  "create",
  "elementFactory",
  "globalConnect",
];

PalettProvider.prototype.getPaletteEntries = function (element) {
  const { create, elementFactory } = this;

  function createTask() {
    return function (event) {
      const shape = elementFactory.createShape({
        type: "bpmn:Task",
      });

      console.log(shape);
      create.start(event, shape);
    };
  }

  return {
    "create.lindaidai-task": {
      group: "model",
      className: "icon-custom lindaidai-task",
      title: "创建一个类型为lindaidai-task的任务节点",
      action: {
        dragstart: createTask(),
        click: createTask(),
      },
    },
  };
};
